package com.imooc.trading_system.config;

import com.imooc.trading_system.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Feng zhaoxi
 * @date 2022/4/23 4:11 下午
 * @Description
 */
@Configuration
@Slf4j
public class interceptorConfig implements WebMvcConfigurer {
    public LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor())
                //拦截的路径
                .addPathPatterns(
                        "/api/user/**",
                        "/api/product/**",
                        "/api/address/**",
                        "/api/order/**",
                        "/api/router/**",
                        "/api/wallet/**"
//                        "/api/issue/**",
//                        "/api/data_factory/**",
//                        "/api/tools/**"
                )

                //不拦截的路径
                .excludePathPatterns("/api/user/login", "/api/user/register","/api/user/get_kaptcha");
    }
}
